package com.gzu.emr.service.impl;

import com.gzu.emr.dto.Drug;
import com.gzu.emr.mapper.DrugMapper;
import com.gzu.emr.service.DrugService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrugServiceImpl implements DrugService {

    @Resource
    private DrugMapper drugMapper;

    @Override
    public List<Drug> listDrug() {
        return drugMapper.listDrug();
    }

    @Override
    public List<Drug> getDrugByName(String name) {

        //exception

        //模糊查询
        name = "%" + name + "%";
        return drugMapper.selectDrugByName(name);
    }

    @Override
    public List<Drug> getDrugByCode(String code) {

        //exception

        //模糊查询
        code = "%" + code + "%";
        return drugMapper.selectDrugByCode(code);
    }

    @Override
    public List<Drug> getDrugByGenericName(String genericName) {

        //exception

        //模糊查询
        genericName = "%" + genericName + "%";
        return drugMapper.selectDrugByGenericName(genericName);
    }
}
